#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer/qtquick2applicationviewer.h"
#include <mainmodel.h>
#include <QtQuick>
#include <Core/idle.h>
#include <optraapplication.h>


int main(int argc, char *argv[])
{
    QByteArray data = "1";
    qputenv("QML_IMPORT_TRACE", data);

    Models::MainModel model;
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;

    QQmlContext *ctxt = viewer.rootContext();
    ctxt->setContextProperty("MainModel", &model);
    viewer.setSource(QUrl("qrc:/GUI/qml/GUI/main.qml"));

    viewer.showExpanded();
//    Core::Idle::SingleShot(8000, [&model]()
//    {
//        model.setDisplayName("aaaaaaaaaaaaaaaaaa"); }
//    );
    Optra::OptraApplication::Instance()->Initialize();

    QObject::connect(&app, &QGuiApplication::aboutToQuit, []()
    {
        Optra::OptraApplication::Instance()->Finalize();
    });

    return app.exec();
}
